Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup faucet for sepolia env #1563

Merged
merged 7 commits into from
Sep 29, 2023
Merged

Setup faucet for sepolia env #1563

merged 7 commits into from
Sep 29, 2023

Conversation

BedrockSquirrel
Copy link
Collaborator

Why this change is needed

  • Sepolia testing is easier with a faucet.
  • We can probably use this faucet for early partners and users too.
  • The testnet deploy was showing red for sepolia because of the faucet step

What changes were made as part of this PR

Add config

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

@@ -32,6 +32,10 @@ const (
serverPortName = "serverPort"
serverPortDefault = 80
serverPortUsage = "Port where the web server binds to"

defaultAmountName = "defaultAmount"
defaultAmountDefault = 100.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float ?

@@ -41,15 +45,25 @@ func parseCLIArgs() *faucet.Config {
faucetPK := flag.String(faucetPKName, faucetPKDefault, faucetPKUsage)
jwtSecret := flag.String(jwtSecretName, jwtSecretDefault, jwtSecretUsage)
serverPort := flag.Int(serverPortName, serverPortDefault, serverPortUsage)
defaultAmount := flag.Float64(defaultAmountName, defaultAmountDefault, defaultAmountUsage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any need for it to be a float ?

Comment on lines 63 to 69
func toWei(amount *float64) *big.Int {
amtFloat := new(big.Float).SetFloat64(*amount)
weiFloat := new(big.Float).Mul(amtFloat, big.NewFloat(1e18))
// don't care about the accuracy here, float should have less than 18 decimal places
wei, _ := weiFloat.Int(nil)
return wei
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps gethcommon.ParseEther(ethValue) is a better alternative.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does sound better but I can't find it. I've changed 1e18 magic number to use geth's params.Ether but seems like in geth they mostly just do the multiplication.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could swear there was a ParseEther(string), but had a double look and nothing. params.Ether sounds good.

WrappedUSDC = "usdc"
_timeout = 60 * time.Second
NativeToken = "eth"
DeprecatedNativeToken = "obx" // leaving this in temporarily for tooling that is getting native funds using `/obx` URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to rip the band aid straight off imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed with Moray, we want to make it less painful to transition. No need to break the discord faucet and e2e tests unnecessarily even if it's an easy fix. I'll add a todo to remove it.


defaultAmountName = "defaultAmount"
defaultAmountDefault = 100.0
defaultAmountUsage = "Default amount of token to fund (in ETH)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a pet annoyance, I'll leave it to you consideration. The flags receive ETH but the config struct receives WEI. Worth normalizing one way or the other imo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should mostly use explicit big.Int for token values everywhere in code, seems to be mostly what geth does.

But the CLI is a human configured interface, imo it makes sense for it to use human readable values but not to leak that into other layers. If I'm checking the config for each env I don't want to have to count the zeroes ideally.

errorHandler(c, fmt.Errorf("unable to fund request %w", err), faucetServer.Logger)
return
}
r.POST("/fund/:token", fundingHandler(faucetServer, defaultAmount))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a comment be added here to take care of this endpoint before deploying to sepolia ?

@BedrockSquirrel BedrockSquirrel merged commit 341cc51 into main Sep 29, 2023
@BedrockSquirrel BedrockSquirrel deleted the matt/sepolia-faucet branch September 29, 2023 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants